import request from '@/config/axios'

// 持仓数据 VO
export interface PositionVO {
  id: number // ID
  timePeriod: string // 时段
  systemBuyableQuantity: string // 系统可买量
  pendingTransferIn: string // 待操作转入
  actualBuyableQuantity: string // 实际可买量
  systemSellableQuantity: string // 系统可卖量
  pendingTransferOut: string // 待操作转出
  actualSellableQuantity: string // 实际可卖量
  tradingId: number // 交易单元ID
  tradingName: string // 交易单元名称
}

// 持仓数据 API
export const PositionApi = {
  // 查询持仓数据分页
  getPositionPage: async (params: any) => {
    return await request.get({ url: `/dd/position/page`, params })
  },
  // 查询持仓SUM数据
  getPositionSumList: async (params: any) => {
    return await request.get({ url: `/dd/position/sumList`, params })
  },
  
  // 查询持仓数据详情
  getPosition: async (id: number) => {
    return await request.get({ url: `/dd/position/get?id=` + id })
  },

  // 新增持仓数据
  createPosition: async (data: PositionVO) => {
    return await request.post({ url: `/dd/position/create`, data })
  },

  // 修改持仓数据
  updatePosition: async (data: PositionVO) => {
    return await request.put({ url: `/dd/position/update`, data })
  },

  // 删除持仓数据
  deletePosition: async (id: number) => {
    return await request.delete({ url: `/dd/position/delete?id=` + id })
  },

  // 导出持仓数据 Excel
  exportPosition: async (params) => {
    return await request.download({ url: `/dd/position/export-excel`, params })
  },
}
